#-------------------------------------------------------------------------------
# Name:        HJ Engine Demo (Debug)
# Purpose:
#
# Author:      Pablo
#
# Created:     07/03/2012
# Copyright:   (c) Monxcleyr Productions 2012
# Licence:     GPL v3
#-------------------------------------------------------------------------------
#!/usr/bin/env python


from lib.game import main as game
from lib.game import error
import sys, os, logging, pygame

filename = os.path.join(os.path.split(sys.argv[0])[0], 'hj.log')
if os.path.exists(filename):
  open(filename, 'w').close()
logging.basicConfig(filename= filename, format='%(asctime)s %(levelname)s: %(message)s', datefmt='(%m/%d/%Y %I:%M:%S %p)', level=logging.DEBUG)

exception = False

def main():

  sys.argv.append('-nologo')
  sys.argv.append('-debug')
  sys.argv.append('-nofps')
  exception = False

  try:
    game.main()
  except Exception, err:
    logging.exception('Exception thrown:')
    exception = True
    pygame.quit()
    errorscreen = error.Error(err)

  if exception:
    logging.info('Displaying error screen.')
    errorscreen.draw()


if __name__ == '__main__':
  main()
